package com.lovo.ssc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lovo.ssc.bean.LevelBean;
import com.lovo.ssc.mapper.LevelMapper;
import com.lovo.ssc.service.ILevelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户等级表，不同等级对应不同的折扣率 服务实现类
 * </p>
 *
 * @author lovo
 * @since 2022-07-11
 */
@Service
public class LevelServiceImpl extends ServiceImpl<LevelMapper, LevelBean> implements ILevelService {

    /**
     * 通过等级名查询折扣
     * @param levelName 等级名
     * @return 折扣率
     */
    @Override
    public float findDiscount(String levelName) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("levelName", levelName);
        LevelBean levelBean = baseMapper.selectOne(qw);
        return levelBean.getDiscount();
    }
}
